#include <cstdio>
#include <cmath>
#include <cstdlib>
#define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))<eps)
struct point{double x,y;};
struct line{point a,b;};

double xmult(point p1,point p2,point p0){
        return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
}
point intersection(line u,line v){
        point ret=u.a;
        double t=((u.a.x-v.a.x)*(v.a.y-v.b.y)-(u.a.y-v.a.y)*(v.a.x-v.b.x))
                        /((u.a.x-u.b.x)*(v.a.y-v.b.y)-(u.a.y-u.b.y)*(v.a.x-v.b.x));
        ret.x+=(u.b.x-u.a.x)*t;
        ret.y+=(u.b.y-u.a.y)*t;
        return ret;
}
point barycenter(point a,point b,point c){
        line u,v;
        u.a.x=(a.x+b.x)/2;
        u.a.y=(a.y+b.y)/2;
        u.b=c;
        v.a.x=(a.x+c.x)/2;
        v.a.y=(a.y+c.y)/2;
        v.b=b;
        return intersection(u,v);
}
point barycenter(int n,point* p){
        point ret,t;
        double t1=0,t2;
        int i;
        ret.x=ret.y=0;
        for (i=1;i<n-1;i++)
                if (fabs(t2=xmult(p[0],p[i],p[i+1]))>eps){
                        t=barycenter(p[0],p[i],p[i+1]);
                        ret.x+=t.x*t2;
                        ret.y+=t.y*t2;
                        t1+=t2;
                }
        if (fabs(t1)>eps)
                ret.x/=t1,ret.y/=t1;
        return ret;
}

point p1,p2;
int graham_cp(const void* a,const void* b){
        double ret=xmult(*((point*)a),*((point*)b),p1);
        return zero(ret)?(xmult(*((point*)a),*((point*)b),p2)>0?1:-1):(ret>0?1:-1);
}
void _graham(int n,point* p,int& s,point* ch){
        int i,k=0;
        for (p1=p2=p[0],i=1;i<n;p2.x+=p[i].x,p2.y+=p[i].y,i++)
                if (p1.y-p[i].y>eps||(zero(p1.y-p[i].y)&&p1.x>p[i].x))
                        p1=p[k=i];
        p2.x/=n,p2.y/=n;
        p[k]=p[0],p[0]=p1;
        qsort(p+1,n-1,sizeof(point),graham_cp);
        for (ch[0]=p[0],ch[1]=p[1],ch[2]=p[2],s=i=3;i<n;ch[s++]=p[i++])
                for (;s>2&&xmult(ch[s-2],p[i],ch[s-1])<-eps;s--);
}
int graham(int n,point* p,point* convex,int maxsize=1,int dir=1){
        point* temp=new point[n];
        int s,i;
        _graham(n,p,s,temp);
        for (convex[0]=temp[0],n=1,i=(dir?1:(s-1));dir?(i<s):i;i+=(dir?1:-1))
                if (maxsize||!zero(xmult(temp[i-1],temp[i],temp[(i+1)%s])))
                        convex[n++]=temp[i];
        delete []temp;
        return n;
}
point intersection(point u1,point u2,point v1,point v2){
        point ret=u1;
        double t=((u1.x-v1.x)*(v1.y-v2.y)-(u1.y-v1.y)*(v1.x-v2.x))
                        /((u1.x-u2.x)*(v1.y-v2.y)-(u1.y-u2.y)*(v1.x-v2.x));
        ret.x+=(u2.x-u1.x)*t;
        ret.y+=(u2.y-u1.y)*t;
        return ret;
}
point ptoline(point p,point l1,point l2){
        point t=p;
        t.x+=l1.y-l2.y,t.y+=l2.x-l1.x;
        return intersection(p,t,l1,l2);
}
int dot_online_in(point p,point l1,point l2){
        return zero(xmult(p,l1,l2))&&(l1.x-p.x)*(l2.x-p.x)<eps&&(l1.y-p.y)*(l2.y-p.y)<eps;
}
int dot_online_ex(point p,point l1,point l2){
        return dot_online_in(p,l1,l2)&&(!zero(p.x-l1.x)||!zero(p.y-l1.y))&&(!zero(p.x-l2.x)||!zero(p.y-l2.y));
}
point p[ 50001 ], convex[ 50001 ], pt;
int n, m;

void init( )
{
        int i;
        scanf("%d", &n);
        for ( i = 0; i < n; i++ )
                scanf("%lf%lf", &p[ i ].x, &p[ i ].y);
        pt = barycenter( n, p );
        m = graham( n, p, convex, 0 );
}

void work( )
{
        int i, ans = 0;
        point pp;
        for ( i = 1; i < m; i++ )
        {
                pp = ptoline( pt, convex[ i - 1 ], convex[ i ] );
                if ( dot_online_ex( pp, convex[ i - 1 ], convex[ i ] ) )
                        ans++;
        }
        pp = ptoline( pt, convex[ m - 1 ], convex[ 0 ] );
        if ( dot_online_ex( pp, convex[ m - 1 ], convex[ 0 ] ) )
                ans++;
        printf("%d\n", ans);
}

int main( )
{
        int t;
        scanf("%d", &t);
        while ( t-- )
        {
                init( );
                work( );
        }
        return 0;
}